package com.example.mobile2121606109ycg0407;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivityTip2 extends AppCompatActivity {

    private EditText edtTxtMainNum2A;
    private EditText edtTxtMainNum2B;
    private EditText edtTxtMainNum2C;
    private TextView tvMain2Result;
    private Button btnMain2Result;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_tip2);
        initView();

        btnMain2Result.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //获取A、B、C
                int A2 = Integer.parseInt(edtTxtMainNum2A.getText().toString());
                int B2 = Integer.parseInt(edtTxtMainNum2B.getText().toString());
                int C2 = Integer.parseInt(edtTxtMainNum2C.getText().toString());
                //定义最大值
                int max;
                //最大值判断
                max = A2 >= B2 ? A2 : B2;
                max = max >= C2 ? max : C2;
                //输出结果
                tvMain2Result.setText(String.valueOf(max));
            }
        });
    }

    private void initView() {
        edtTxtMainNum2A = (EditText) findViewById(R.id.edtTxtMainNum2_A);
        edtTxtMainNum2B = (EditText) findViewById(R.id.edtTxtMainNum2_B);
        edtTxtMainNum2C = (EditText) findViewById(R.id.edtTxtMainNum2_C);
        tvMain2Result = (TextView) findViewById(R.id.tvMain2_Result);
        btnMain2Result = (Button) findViewById(R.id.btnMain2_Result);
    }
}